import server from '@/config/server/index.js';
import ruleOpt from './rule.js'
const api = {
    getByProjectName: server.api().get('/hft-portal/project/getByProjectName')
}

// 项目名称
function getByProjectName(projectName,params) {
  let data = {
    projectName,
    ...params
  }
  return api.getByProjectName.fetch(data).then(res => {
    return res.list.map(item => {
      item.key = item.id
      item.value = item.projectName
      return item
    })
  })
}

function createPorject(opt = {},params) { // key title
  return {
    title: opt.title,
    key: opt.key,
    placeholder: '请输入' + opt.title,
    select: {
      filterable: true,
      options: opt.options || [],
      remote: (key) => {
        return getByProjectName(key, params)
      }
    },
    data: opt.data,
    change: opt.change
  }
}

export default {
    createPorject
}